package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SalaryRecord;
import com.ruoyi.system.service.ISalaryRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 薪资记录Controller
 * 
 * @author ruoyi
 * @date 2023-11-17
 */
@RestController
@RequestMapping("/system/salaryRecord")
public class SalaryRecordController extends BaseController
{
    @Autowired
    private ISalaryRecordService salaryRecordService;

    /**
     * 查询薪资记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:salaryRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(SalaryRecord salaryRecord)
    {
        startPage();
        List<SalaryRecord> list = salaryRecordService.selectSalaryRecordList(salaryRecord);
        return getDataTable(list);
    }

    /**
     * 导出薪资记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:salaryRecord:export')")
    @Log(title = "薪资记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SalaryRecord salaryRecord)
    {
        List<SalaryRecord> list = salaryRecordService.selectSalaryRecordList(salaryRecord);
        ExcelUtil<SalaryRecord> util = new ExcelUtil<SalaryRecord>(SalaryRecord.class);
        util.exportExcel(response, list, "薪资记录数据");
    }

    /**
     * 获取薪资记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:salaryRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(salaryRecordService.selectSalaryRecordById(id));
    }

    /**
     * 新增薪资记录
     */
    @PreAuthorize("@ss.hasPermi('system:salaryRecord:add')")
    @Log(title = "薪资记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SalaryRecord salaryRecord)
    {
        return toAjax(salaryRecordService.insertSalaryRecord(salaryRecord));
    }

    /**
     * 修改薪资记录
     */
    @PreAuthorize("@ss.hasPermi('system:salaryRecord:edit')")
    @Log(title = "薪资记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SalaryRecord salaryRecord)
    {
        return toAjax(salaryRecordService.updateSalaryRecord(salaryRecord));
    }

    /**
     * 删除薪资记录
     */
    @PreAuthorize("@ss.hasPermi('system:salaryRecord:remove')")
    @Log(title = "薪资记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(salaryRecordService.deleteSalaryRecordByIds(ids));
    }
}
